export namespace analyze{
    export const methodExecutionTime=()=>{
        return function (
            target:Object,
            prototypeKey:string|symbol,
            prototypeDescriptor:PropertyDescriptor
        ){
            const origFunc = prototypeDescriptor.value
    
            prototypeDescriptor.value = function (...args:any){
                const startTime = new Date().getTime()
                const result = origFunc.apply(this,args)
                const endTime = new Date().getTime()
                console.error(`method:${prototypeKey.toString()} execution time:${endTime - startTime} ms`)
                return result
            }
            return prototypeDescriptor
        }
    };
    
    export const methodExecutionTimeAsync=()=>{
        return function (
            target:Object,
            prototypeKey:string|symbol,
            prototypeDescriptor:PropertyDescriptor
        ){
            const origFunc = prototypeDescriptor.value
    
            prototypeDescriptor.value = async function (...args: any) {
                const startTime = new Date().getTime()
                const result = await origFunc.apply(this, args)
                const endTime = new Date().getTime()
                console.error(`method:${prototypeKey.toString()} execution time:${endTime - startTime} ms`)
                return result
            }
            return prototypeDescriptor
        }
    }
}